<?php
class Request {
  	function __construct(&$locator) {	
		if (ini_get('magic_quotes_gpc')) {
			$_GET    = $this->stripSlashes($_GET);
			$_POST   = $this->stripSlashes($_POST);
			$_COOKIE = $this->stripSlashes($_COOKIE);
			$_SERVER = $this->stripSlashes($_SERVER);
			$_ENV    = $this->stripSlashes($_ENV);
		}
	}
						        
  	function get($key, $type = 'GET', $default = NULL) {
		switch (strtoupper($type)) {
			case 'GET':
				$data = $_GET;
				break;
			case 'POST':
				$data = $_POST;
				break;
			case 'COOKIE':
				$data = $_COOKIE;
				break;
		}
		
		return (isset($data[$key]) ? $data[$key] : $default);
	}
    
	function has($key, $type = 'GET') {
		switch (strtoupper($type)) {
			case 'GET':
				return isset($_GET[$key]);
				break;
			case 'POST':
				return isset($_POST[$key]);
				break;
			case 'COOKIE':
				return isset($_COOKIE[$key]); 
				break;
		}	
	}
	
	function set($key, $value, $type = 'GET') {
		switch (strtoupper($type)) {
			case 'GET':
				return $_GET[$key] = $value;
				break;
			case 'POST':
				return $_POST[$key] = $value;
				break;
		}	
	}
	
	function isPost() {
		return (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST');
	}

	function isSecure() {
		return (@$_SERVER['HTTPS'] == 'on');
	}
			
  	function stripSlashes($data) {
    	if (is_array($data)) {
	  		foreach ($data as $key => $value) {
	    		$data[$key] = $this->stripSlashes($value);
	  		}
		} else {
	  		$data = stripslashes($data);
		}
	
		return $data;
	}
}
?>